/* 
 * File:   FiguraTest.cpp
 * Author: max
 *
 * Created on Oct 4, 2012, 8:55:38 PM
 */

#include <stdlib.h>
#include <iostream>

#include <Figura.h>
#include <FiguraException.h>
#include <FiguraFactory.h>
#include <FiguraFactoryException.h>

using namespace TP::Grafica::Componentes;

/*
 * Simple C++ Test Suite
 */

void test1() {

    std::cout << "FiguraTest test 1" << std::endl;

    
    try
    {
        FiguraFactory factory;
        Figura* figura = factory.crear("R,0,0,0");

        if (figura)
        {
            if (!(figura->getTipo() == 'R'))
                std::cout << "%TEST_FAILED% time=0 testname=test1 (FiguraTest) message=La figura no posee el tipo indicado en el descriptor."<< std::endl;

            if (!(figura->getPosicion().getFila() == 0 && figura->getPosicion().getColumna() == 0))
                std::cout << "%TEST_FAILED% time=0 testname=test1 (FiguraTest) message=La figura no posee la posicion indicada en el descriptor."<< std::endl;
            
            if (! (figura->getPosicionGrafica().getFila() == -9 && figura->getPosicionGrafica().getColumna() == -34))
                std::cout << "%TEST_FAILED% time=0 testname=test1 (FiguraTest) message=La posicion grafica de la figura es fruta."<< std::endl;
            
            delete figura;
        }
        else
            std::cout << "%TEST_FAILED% time=0 testname=test1 (FiguraTest) message=La figura no fue instanciada."<< std::endl;
        
        
        
    }
    catch (FiguraException& pEx){
        std::cout << "%TEST_FAILED% time=0 testname=test1 (FiguraTest) message=FiguraException.  " << pEx.what() << std::endl;
    }
    catch (FiguraFactoryException& pEx)
    {
        std::cout << "%TEST_FAILED% time=0 testname=test1 (FiguraTest) message=FiguraFactoryException.  " << pEx.what() << std::endl;
    }
    catch (exception& pEx)
    {
        std::cout << "%TEST_FAILED% time=0 testname=test1 (FiguraTest) message=" << pEx.what() << std::endl;
    }
    
}

void test2() {
    std::cout << "FiguraTest test 2" << std::endl;
    std::cout << "%TEST_FAILED% time=0 testname=test2 (FiguraTest) message=error message sample" << std::endl;
}

int main(int argc, char** argv) {
    std::cout << "%SUITE_STARTING% FiguraTest" << std::endl;
    std::cout << "%SUITE_STARTED%" << std::endl;

    std::cout << "%TEST_STARTED% test1 (FiguraTest)" << std::endl;
    test1();
    std::cout << "%TEST_FINISHED% time=0 test1 (FiguraTest)" << std::endl;

    std::cout << "%TEST_STARTED% test2 (FiguraTest)\n" << std::endl;
    test2();
    std::cout << "%TEST_FINISHED% time=0 test2 (FiguraTest)" << std::endl;

    std::cout << "%SUITE_FINISHED% time=0" << std::endl;

    return (EXIT_SUCCESS);
}

